package com.jniu.customviewprogram.actrivity;

import android.content.Intent;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.jniu.customviewprogram.R;
import com.jniu.customviewprogram.adapter.MainAdapter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    public static final String[] title = {"仿Ios弹框" , "不可滑动的ViewPager" , "圆形ImageView" , "可右划关闭的activity"};
    public static final Class[] classes = {IosDialogActivity.class , NoScrollViewPagerActivity.class , CircleImageViewActivity.class , SlideBackActivity.class};

    private RecyclerView recyclerView;
    private List<String> titles;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initData();
        initView();
    }

    private void initData() {
        titles = new ArrayList<>();
        Collections.addAll(titles, title);
    }

    private void initView() {
        recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        MainAdapter adapter = new MainAdapter(this, titles);
        recyclerView.setAdapter(adapter);
        adapter.setOnItemClickListener(new MainAdapter.OnItemClickListener() {
            @Override
            public void onClick(int position) {
                startActivity(classes[position]);
            }
        });
    }

    public void startActivity(Class clazz){
        startActivity(new Intent(this,clazz));
    }
}
